package 多线程.Lambda推导在Thread的应用;

/**
 * lambda推导 + 参数 + 返回值
 * （lambda是为了避免内部类定义过多）
 */
public class LambdaTest03 {
    //2.静态内部类
    static class want2 implements IWant {
        @Override
        public int lambda(int a, int b) {

            return a + b;
        }


    }

    public static void main(String[] args) {
//1
        IWant want = new want();
        System.out.println(want.lambda(1, 1));
//2
        want = new want2();
        System.out.println(want.lambda(2, 2));
//3
        want = new IWant() {
            @Override
            public int lambda(int a, int b) {
                return a + b;
            }
        };
        System.out.println(want.lambda(3, 3));
//4
        want = (a, v) -> {
            return a+v;
        };
        System.out.println(want.lambda(4, 4));

        //5
        want = (a, v) -> a+v;

        System.out.println(want.lambda(5, 5));
    }
}

interface IWant {
    int lambda(int a, int b);

}

//1.外部类
class want implements IWant {
    @Override
    public int lambda(int a, int b) {

        return a + b;
    }
}
